package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServicePicture;
import com.ruoyi.service.service.IServicePictureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图片信息表Controller
 * 
 * @author ZDL
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/service/picture")
public class ServicePictureController extends BaseController
{
    @Autowired
    private IServicePictureService servicePictureService;

    /**
     * 查询图片信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:picture:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServicePicture servicePicture)
    {
        startPage();
        List<ServicePicture> list = servicePictureService.selectServicePictureList(servicePicture);
        return getDataTable(list);
    }

    /**
     * 导出图片信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:picture:export')")
    @Log(title = "图片信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServicePicture servicePicture)
    {
        List<ServicePicture> list = servicePictureService.selectServicePictureList(servicePicture);
        ExcelUtil<ServicePicture> util = new ExcelUtil<ServicePicture>(ServicePicture.class);
        util.exportExcel(response, list, "图片信息表数据");
    }

    /**
     * 获取图片信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:picture:query')")
    @GetMapping(value = "/{pictureId}")
    public AjaxResult getInfo(@PathVariable("pictureId") Long pictureId)
    {
        return success(servicePictureService.selectServicePictureByPictureId(pictureId));
    }

    /**
     * 新增图片信息表
     */
    @PreAuthorize("@ss.hasPermi('service:picture:add')")
    @Log(title = "图片信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServicePicture servicePicture)
    {
        return toAjax(servicePictureService.insertServicePicture(servicePicture));
    }

    /**
     * 修改图片信息表
     */
    @PreAuthorize("@ss.hasPermi('service:picture:edit')")
    @Log(title = "图片信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServicePicture servicePicture)
    {
        return toAjax(servicePictureService.updateServicePicture(servicePicture));
    }

    /**
     * 删除图片信息表
     */
    @PreAuthorize("@ss.hasPermi('service:picture:remove')")
    @Log(title = "图片信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pictureIds}")
    public AjaxResult remove(@PathVariable Long[] pictureIds)
    {
        return toAjax(servicePictureService.deleteServicePictureByPictureIds(pictureIds));
    }
}
